package com.ruoyi.littleRedBook.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.littleRedBook.domain.pojo.Coupon;
import com.ruoyi.littleRedBook.domain.pojo.ReceiveRecord;
import com.ruoyi.littleRedBook.domain.pojo.User;
import com.ruoyi.littleRedBook.domain.vo.receiveRecordVO;
import com.ruoyi.littleRedBook.mapper.ReceiveRecordMapper;
import com.ruoyi.littleRedBook.service.CouponService;
import com.ruoyi.littleRedBook.service.ReceiveRecordService;

import com.ruoyi.littleRedBook.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 领取记录表 服务实现类
 * </p>
 *
 * @author
 * @since
 */
@Service
public class ReceiveRecordServiceImpl extends ServiceImpl<ReceiveRecordMapper, ReceiveRecord> implements ReceiveRecordService {


    @Autowired
    private CouponService couponService;
    @Autowired
    private UserService userService;
    @Override
    public receiveRecordVO list(ReceiveRecord receiveRecord) {
        //根据用户id查询用户信息
        User user = userService.getById(receiveRecord.getUserId());
        //根据优惠券id查询优惠券信息
        Coupon coupon=couponService.getById(receiveRecord.getCouponId());
        receiveRecordVO receiveRecordVO=new receiveRecordVO();
        receiveRecordVO.setUser(user);
        receiveRecordVO.setCoupon(coupon);
        receiveRecordVO.setReceiveRecord(receiveRecord);
        return receiveRecordVO;
    }
}
